home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / idletime / idleTime.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-25  |  1.4 KB  |  57 lines

  1. /*
  2.  * A program to test and calibrate the idle time counter.
  3.  */
  4.  
  5. #include "sprite.h"
  6. #include "status.h"
  7. #include "stdio.h"
  8. #include "proc.h"
  9. #include "sysStats.h"
  10. #include "kernel/sched.h"
  11. #include "option.h"
  12.  
  13. Time time = {10, 0};
  14.  
  15. Option optionArray[] = {
  16.     {OPT_INT, "s", (Address)&time.seconds, "Seconds to sleep\n"},
  17. };
  18. int numOptions = sizeof(optionArray) / sizeof(Option);
  19.  
  20. Time startTime, endTime;
  21. Sched_Instrument startSchedStats, endSchedStats;
  22.  
  23. main(argc, argv)
  24.     int argc;
  25.     char *argv[];
  26. {
  27.     register ReturnStatus status = SUCCESS;
  28.  
  29.     status = Sys_Stats(SYS_SCHED_STATS, 0, &startSchedStats);
  30.     argc = Opt_Parse(argc, argv, optionArray, numOptions, 0);
  31.     fprintf(stderr, "Sleeping for %d seconds...", time.seconds);
  32.     fflush(stderr);
  33.     status = Sys_GetTimeOfDay(&startTime, NULL, NULL);
  34.     if (status != SUCCESS) {
  35.     Stat_PrintMsg(status, "Error in Sys_GetTimeOfDay");
  36.     exit(status);
  37.     }
  38.     status = Sys_Stats(SYS_SCHED_STATS, 0, &startSchedStats);
  39.     if (status != SUCCESS) {
  40.     Stat_PrintMsg(status, "Error in Sys_Stats");
  41.     exit(status);
  42.     }
  43.     /*
  44.      * Sleep for a while...
  45.      */
  46.     Sync_WaitTime(time);
  47.     /*
  48.      * Take ending statistics and print user, system, and elapsed times.
  49.      */
  50.     Sys_GetTimeOfDay(&endTime, NULL, NULL);
  51.     Sys_Stats(SYS_SCHED_STATS, 0, &endSchedStats);
  52.     Time_Subtract(endTime, startTime, &endTime);
  53.     PrintIdleTime(stderr, &startSchedStats, &endSchedStats, &endTime);
  54.  
  55.     exit(status);
  56. }
  57.